"""
MCP Server 测试 client

1. 这是一个基于 FastMCP 框架的 MCP 服务器
2. 服务器运行在端口 3002，通过 HTTP 传输协议提供服务


@Author: rslai
@Email: netlrs@163.com
@Date: 2025-09-17
"""
import asyncio
from fastmcp import Client

# 使用 config 配置方式
config = {
    "mcpServers": {
        "server": {
            "url": "http://127.0.0.1:3002/mcp_atlas", 
            "transport": "streamable-http"
        }
    }
}

# 初始化客户端
client = Client(config)

async def main():
    async with client:
        # print("===== 调用 tools 列表查询 =====")
        # tools = await client.list_tools()
        # print(tools)

        # print("===== 调用工具 =====")
        output = await client.call_tool("search_international_one_way_by_fliggy", {"departure": "北京", "arrival": "洛杉矶", "departure_date": "2025-09-28"})
        extracted_text = output.content[0].text
        print(extracted_text)

if __name__ == "__main__":
    asyncio.run(main())